﻿namespace DICOM_PROJECT.Migrations
{
    using DICOM_PROJECT.Models;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<DICOM_PROJECT.DAL.HospitalContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(DICOM_PROJECT.DAL.HospitalContext context)
        {
            var roles = new List<Role>{
                new Role{RoleName="Patient", Description="For patient"},
                new Role{RoleName="Doctor", Description="For doctor"},
                new Role{RoleName="Radiologist", Description="For radiologist"},
                new Role{RoleName="Assistant", Description="For assistant"},
                new Role{RoleName="Admin", Description="For admin"}
            };
            roles.ForEach(r => context.Roles.Add(r));
            context.SaveChanges();
            var userprofiles = new List<UserProfile>
            {
	            new Doctor{Password="123", SocialID="024778760", Name="Võ Thành Long", Birthday=DateTime.Parse("1992-2-22"), Male=true, Address="HCM", Phone="098652347", UserType="Doctor",
                Roles = new List<Role>{roles[1], roles[0]}},
	            new Doctor{Password="123", SocialID="024778761", Name="Võ Thị Mỹ Linh", Birthday=DateTime.Parse("1992-1-1"), Male=false, Address="HCM", Phone="0902001002", UserType="Doctor",
                Roles = new List<Role>{roles[1], roles[0]}},
	            new Radiologist{Password="123", SocialID="024778762", Name="Âu Dương Phong", Birthday=DateTime.Parse("1992-12-31"), Male=true, Address="Hà Nội", Phone="0902113114", UserType="Radiologist",
                Roles = new List<Role>{roles[2], roles[0]}},
	            new Patient{Password="123", SocialID="024778763", Name="Dương Minh Anh", Birthday=DateTime.Parse("1995-3-4"), Male=true, Address="Hải Phòng", Phone="0909888999", UserType="Patient",
                Roles = new List<Role>{roles[0]}},
	            new Patient{Password="123", SocialID="024778764", Name="Đỗ Kim Trang", Birthday=DateTime.Parse("1995-1-4"), Male=false, Address="HCM", Phone="0909999999", UserType="Patient",
                Roles = new List<Role>{roles[0]}},
	            new Patient{Password="123", SocialID="024778765", Name="Trần Lê Thúy Anh", Birthday=DateTime.Parse("1992-3-4"), Male=false, Address="Hải Phòng", Phone="0909002003", UserType="Patient",
                Roles = new List<Role>{roles[0]}},
                new Assistant{Password="123", SocialID="024778766", Name="Nguyễn Thị Bích Hằng", Birthday=DateTime.Parse("1992-12-31"), Male=false, Address="Hà Nội", Phone="0902113114", UserType="Assistant",
                Roles = new List<Role>{roles[3], roles[0]}},
                new Admin{Password="123", SocialID="024778767", Name="Trần Thanh Phong", Birthday=DateTime.Parse("1992-12-31"), Male=true, Address="Hà Nội", Phone="0902113114", UserType="Admin",
                Roles = new List<Role>{roles[4], roles[0]}}
            };
            userprofiles.ForEach(u => context.UserProfiles.Add(u));
            context.SaveChanges();
            var visits = new List<Visit>
            {
                new Visit{UserProfileID=4, CreateDoctorID=1, CreateDate=DateTime.Now, UpdateDoctorID=1, UpdateDate=DateTime.Now, Symptom="abc", Diagnosis="def", Treatment="ghi"},
                new Visit{UserProfileID=4, CreateDoctorID=1, CreateDate=DateTime.Now, UpdateDoctorID=2, UpdateDate=DateTime.Now, Symptom="abc", Diagnosis="def", Treatment="ghi"},
                new Visit{UserProfileID=4, CreateDoctorID=2, CreateDate=DateTime.Now, UpdateDoctorID=1, UpdateDate=DateTime.Now, Symptom="abc", Diagnosis="def", Treatment="ghi"},
                new Visit{UserProfileID=4, CreateDoctorID=2, CreateDate=DateTime.Now, UpdateDoctorID=2, UpdateDate=DateTime.Now, Symptom="abc", Diagnosis="def", Treatment="ghi"}
            };
            visits.ForEach(v => context.Visits.Add(v));
            context.SaveChanges();
            var indicaions = new List<Indication>
            {
	            new Indication{UserProfileID=4, DoctorID=1, CreateDate=DateTime.Now, RadiologistID=3, UpdateDate=DateTime.Now, IndicationInformation="abc", IndicationResult="def"}
            };
            indicaions.ForEach(i => context.Indications.Add(i));
            context.SaveChanges();
        }
    }
}
